home *** CD-ROM | disk | FTP | other *** search
INI File | 2001-09-10 | 2.0 KB | 61 lines |
- [Name]
- 3DBounce - From Matthew's Motion Suite.
- By Matthew Peterson, matthew@pinoko.berkeley.edu
-
- [Description]
- 2-19-2000
- Drop this on a sprite, and it will bounce around the sprite
- track, scaling with perspective as it also bounces in
- the third dimension.
-
- [Parameters]
-
-
- [Frame loaded]
- SpriteVars MP_dbouncestep MP_dbouncedeltax MP_dbouncedeltay MP_dbouncedirection
-
- MP_dbouncedeltax = 3
- MP_dbouncedeltay = 5
- MP_dbouncestep = 1
- MP_dbouncedirection = 0.5
-
-
- [Idle]
- SpriteVars MP_dbouncestep MP_dbouncedeltax MP_dbouncedeltay MP_dbouncedirection
- LocalVars tempcenterx tempcentery tempscalefactor
- //3D Bounce By Matthew Peterson
- //It is common to have a sprite bounce around the track
- //but why not add a third dimension. This sprite bounces
- //on the walls as well as in and out against an invisible
- //floor. A simple parabolic scaling is used to simulate
- //Depth.
- IF(MP_dbouncestep < 9)
- //Remember the center position so we can restore it.
- tempcenterx = (BoundsLeft + BoundsRight)/2
- tempcentery = (BoundsTop + BoundsBottom)/2
- //See if we are out of bounds so that we can change direction
- if(boundsright > trackwidth)
- MP_dbouncedeltax = - Abs(MP_dbouncedeltax)
- elseif(boundsleft < 0)
- MP_dbouncedeltax = Abs(MP_dbouncedeltax)
- endif
- if(boundsbottom > trackheight)
- MP_dbouncedeltay = - Abs(MP_dbouncedeltay)
- elseif(boundstop< 0)
- MP_dbouncedeltay = Abs(MP_dbouncedeltay)
- endif
- //Undo scaling with a resetmatrix call
- resetmatrix
- //Calculate parabola
- tempscalefactor = 1 - MP_dbouncestep*MP_dbouncestep/100
- scale(tempscalefactor,tempscalefactor)//scale then
- //Restore position with an added movement.
- MoveBy(tempcenterx-(BoundsLeft + BoundsRight)/2 + MP_dbouncedeltax ,MP_dbouncedeltay + tempcentery - (BoundsTop + BoundsBottom)/2)
- //Increase the step
- MP_dbouncestep = MP_dbouncestep + MP_dbouncedirection
- // If we hit the ground, or reach zero 3d velocity reverse step
- if(MP_dbouncestep = 9 or MP_dbouncestep = -1)
- MP_dbouncedirection = -MP_dbouncedirection
- MP_dbouncestep = MP_dbouncestep + MP_dbouncedirection* 2
- endif
- ENDIF